 /* 
 * Copyright 2013 Dominik Korittki, Steffen Gruschka

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

package entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import org.hibernate.validator.constraints.Length;

/**
 * Entität, welche einen Gruppeneintrag repräsentiert.
 * Gruppeneinträge legen die Berechtigungsgruppe für Benutzer fest.
 * @author Dominik K
 * @author Steffen G
 */
@Entity
public class Gruppen implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * id des Eintrages
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    /**
     * Name der Rechtegruppe (zurzeit: admin oder basic)
     */
    @Column(nullable=false)
    @Length(min=1, max=20)
    private String groupID;
    /**
     * Name des Benutzers, für welchen dieser Eintrag gilt
     */
    @Column(nullable=false)
    @Length(min=1, max=50)
    private String username;

    /**
     * Liefert die id
     * @return Die Id
     */
    public Long getId() {
        return id;
    }

    /**
     * Setzt eine neue ID
     * @param id Neue ID
     */
    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Gruppen)) {
            return false;
        }
        Gruppen other = (Gruppen) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Gruppen[ id=" + id + " ]";
    }

    /**
     * Liefert die Group ID
     * @return die Group ID
     */
    public String getGroupID() {
        return groupID;
    }

    /**
     * Setzt eine neue Group ID
     * @param groupID Neue Group ID
     */
    public void setGroupID(String groupID) {
        this.groupID = groupID;
    }

    /**
     * Liefer den Username
     * @return der Username
     */
    public String getUsername() {
        return username;
    }

    /**
     * Setzt einen neuen Username
     * @param username neuer Name
     */
    public void setUsername(String username) {
        this.username = username;
    }
    
}
